﻿using DynamicToolkit;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;

namespace DynamicToolkit.Tests
{
    
    
    /// <summary>
    ///This is a test class for ComparableStringTest and is intended
    ///to contain all ComparableStringTest Unit Tests
    ///</summary>
    [TestClass()]
    public class ComparableStringTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ComparableString Constructor
        ///</summary>
        [TestMethod()]
        public void ComparableStringConstructorTest()
        {
            string str = "str";
            ComparableString target = new ComparableString(str);
            Assert.AreEqual(str, target.Data);
        }

        /// <summary>
        ///A test for Equals
        ///</summary>
        [TestMethod()]
        public void Equals_ShouldReturnTrueWhenComparableStringComparedToWrappedString()
        {
            string str = "str";
            ComparableString target = new ComparableString(str);
            string obj = "str";
            Assert.IsTrue(target.Equals(obj));
        }

        [TestMethod()]
        public void Equals_ShouldReturnFalseWhenComparableStringComparedToDifferentString()
        {
            string str = "str";
            ComparableString target = new ComparableString(str);
            string obj = "different";
            Assert.IsFalse(target.Equals(obj));
        }

        [TestMethod()]
        public void Equals_ShouldReturnTrueWhenComparingComparedStringsWithSameWrappedString()
        {
            string str = "str";
            ComparableString target = new ComparableString(str);
            ComparableString obj = new ComparableString(str);
            Assert.IsTrue(target.Equals(obj));
        }

        /// <summary>
        ///A test for GetHashCode
        ///</summary>
        [TestMethod()]
        public void GetHashCode_ComparableStringShouldHaveTheSameHashCodeAsItsWrappedString()
        {
            string str = "str";
            ComparableString target = new ComparableString(str);
            int expected = str.GetHashCode();
            int actual = target.GetHashCode();
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for ToString
        ///</summary>
        [TestMethod()]
        public void ToString_ComparableStringShouldReturnItsWrappedStringAsToStringValue()
        {
            string str = "str";
            ComparableString target = new ComparableString(str);
            string actual = target.ToString();
            Assert.AreEqual(str, actual);
        }

        [TestMethod()]
        public void op_EqualityTest()
        {
            ComparableString a = new ComparableString("a");
            ComparableString b = new ComparableString("b");
            ComparableString a1 = new ComparableString("a");
            Assert.IsFalse(a == b);
            Assert.IsTrue(a == a1);
        }

        /// <summary>
        ///A test for op_GreaterThan
        ///</summary>
        [TestMethod()]
        public void op_GreaterThanTest()
        {
            ComparableString a = new ComparableString("a");
            ComparableString b = new ComparableString("b");
            ComparableString a1 = new ComparableString("a");
            Assert.IsTrue(b > a);
            Assert.IsFalse(a > b);
            Assert.IsFalse(a > a1);
        }

        /// <summary>
        ///A test for op_GreaterThanOrEqual
        ///</summary>
        [TestMethod()]
        public void op_GreaterThanOrEqualTest()
        {
            ComparableString a = new ComparableString("a");
            ComparableString b = new ComparableString("b");
            ComparableString a1 = new ComparableString("a");
            Assert.IsTrue(b >= a);
            Assert.IsFalse(a >= b);
            Assert.IsTrue(a >= a1);
        }

        /// <summary>
        ///A test for op_Implicit
        ///</summary>
        [TestMethod()]
        public void op_ImplicitTest()
        {
            string str = "str";
            ComparableString expected = new ComparableString(str);
            ComparableString actual = str;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for op_Implicit
        ///</summary>
        [TestMethod()]
        public void op_ImplicitTest1()
        {
            string expected = "str";
            ComparableString c = new ComparableString(expected);
            string actual = c;
            Assert.AreEqual(expected, actual);
        }

        /// <summary>
        ///A test for op_Inequality
        ///</summary>
        [TestMethod()]
        public void op_InequalityTest()
        {
            ComparableString a = new ComparableString("a");
            ComparableString b = new ComparableString("b");
            ComparableString a1 = new ComparableString("a");
            Assert.IsTrue(a != b);
            Assert.IsFalse(a != a1);
        }

        /// <summary>
        ///A test for op_LessThan
        ///</summary>
        [TestMethod()]
        public void op_LessThanTest()
        {
            ComparableString a = new ComparableString("a");
            ComparableString b = new ComparableString("b");
            ComparableString a1 = new ComparableString("a");
            Assert.IsTrue(a < b);
            Assert.IsFalse(b < a);
            Assert.IsFalse(a < a1);
        }

        /// <summary>
        ///A test for op_LessThanOrEqual
        ///</summary>
        [TestMethod()]
        public void op_LessThanOrEqualTest()
        {
            ComparableString a = new ComparableString("a");
            ComparableString b = new ComparableString("b");
            ComparableString a1 = new ComparableString("a");
            Assert.IsTrue(a <= b);
            Assert.IsFalse(b <= a);
            Assert.IsTrue(a <= a1);
        }
    }
}
